home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / networking / rpcdemo / rminfo_svc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  1.9 KB  |  86 lines

  1. /*
  2.  * Please do not edit this file.
  3.  * It was generated using rpcgen.
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include <rpc/rpc.h>
  8. #define _RPCGEN_SVC
  9. #include "rminfo.h"
  10.  
  11. static void rminfoprog_1(struct svc_req *, SVCXPRT *);
  12.  
  13. main(void)
  14. {
  15.     register SVCXPRT *transp;
  16.  
  17.     (void) pmap_unset(RMINFOPROG, RMINFOVERS);
  18.  
  19.     transp = svcudp_create(RPC_ANYSOCK);
  20.     if (transp == NULL) {
  21.         fprintf(stderr, "cannot create udp service.");
  22.         exit(1);
  23.     }
  24.     if (!svc_register(transp, RMINFOPROG, RMINFOVERS, rminfoprog_1, IPPROTO_UDP)) {
  25.         fprintf(stderr, "unable to register (RMINFOPROG, RMINFOVERS, udp).");
  26.         exit(1);
  27.     }
  28.  
  29.     transp = svctcp_create(RPC_ANYSOCK, 0, 0);
  30.     if (transp == NULL) {
  31.         fprintf(stderr, "cannot create tcp service.");
  32.         exit(1);
  33.     }
  34.     if (!svc_register(transp, RMINFOPROG, RMINFOVERS, rminfoprog_1, IPPROTO_TCP)) {
  35.         fprintf(stderr, "unable to register (RMINFOPROG, RMINFOVERS, tcp).");
  36.         exit(1);
  37.     }
  38.  
  39.     svc_run();
  40.     fprintf(stderr, "svc_run returned");
  41.     exit(1);
  42.     /* NOTREACHED */
  43. }
  44.  
  45. static void
  46. rminfoprog_1(struct svc_req *rqstp, SVCXPRT *transp)
  47. {
  48.     union __svcargun {
  49.         int fill;
  50.     } argument;
  51.     xdrproc_t xdr_argument, xdr_result;
  52.     void *result;
  53.     typedef void *(*__svcproc_t)(union __svcargun *, struct svc_req *);
  54.     __svcproc_t local;
  55.  
  56.     switch (rqstp->rq_proc) {
  57.     case NULLPROC:
  58.         (void) svc_sendreply(transp, xdr_void, (char *)NULL);
  59.         return;
  60.  
  61.     case RMINFOPROC_GET:
  62.         xdr_argument = xdr_void;
  63.         xdr_result = xdr_rminfo1;
  64.         local = (__svcproc_t) rminfoproc_get_1;
  65.         break;
  66.  
  67.     default:
  68.         svcerr_noproc(transp);
  69.         return;
  70.     }
  71.     bzero((char *)&argument, sizeof(argument));
  72.     if (!svc_getargs(transp, xdr_argument, &argument)) {
  73.         svcerr_decode(transp);
  74.         return;
  75.     }
  76.     result = (*local)(&argument, rqstp);
  77.     if (result != NULL && !svc_sendreply(transp, xdr_result, result)) {
  78.         svcerr_systemerr(transp);
  79.     }
  80.     if (!svc_freeargs(transp, xdr_argument, &argument)) {
  81.         fprintf(stderr, "unable to free arguments");
  82.         exit(1);
  83.     }
  84.     return;
  85. }
  86.